﻿namespace System.Threading.Tasks
{
    /// <summary>
    /// Interface that can be used by async executing operations to communicate progress and partial results back to caller.
    /// </summary>
    /// <typeparam name="T">type used to pass partial results back to caller</typeparam>
    public interface IProgressNotifier<in T>
    {
        /// <summary>
        /// Allows reporting operation progress back to caller side.
        /// </summary>
        /// <param name="chunk">data chunk for access</param>
        /// <param name="progressPercentage">current progress in the range [0;100]</param>
        void Notify(T chunk, int progressPercentage);

        /// <summary>
        /// Use token inside async operation to cancel operation.
        /// </summary>
        CancellationToken CancellationToken { get; }
    }

    /// <summary>
    /// Interface that can be used by async executing operations to communicate progress back to caller.
    /// </summary>
    public interface IProgressNotifier
    {
        /// <summary>
        /// Allows reporting operation progress back to caller side.
        /// </summary>
        /// <param name="progressPercentage">current progress in the range [0;100]</param>
        void Notify(int progressPercentage);

        /// <summary>
        /// Use token inside async operation to cancel operation.
        /// </summary>
        CancellationToken CancellationToken { get; }
    }
}